<template>
	<view>
		<view>
			<view class="u-font-28 color999 u-p-t-40 u-p-b-20">近四年接收调剂情况</view>
			<view v-if="receiveHeaders.length > 1">
				<wyb-table headerBgColor="#FFFFFF" showLeftAndRightBorder showLeftAndRightBorder ref="table"
					:headers="receiveHeaders" :contents="receiveTableData" width="100%" />
			</view>
		</view>
		<view>
			<view class="u-font-28 color999 u-p-t-40 u-p-b-20">近四年复试/调剂分数线</view>
			<view v-if="retestHeaders.length > 1">
				<wyb-table headerBgColor="#FFFFFF" showLeftAndRightBorder showLeftAndRightBorder ref="table"
					:headers="retestHeaders" :contents="fractionTableData" width="100%" />
			</view>
			<view v-else>无</view>
		</view>
	</view>
</template>

<script>
	import wybTable from '../wyb-table/wyb-table.vue'
	import {
		getAdjustYearInfo,
	} from '@/api/school.js';
	export default {
		props: ['schoolCode', 'collegeCode', 'majorCode'],
		components: {
			wybTable
		},
		data() {
			return {
				fractionTableData: [],
				retestHeaders: [],
				receiveTableData: [],
				receiveHeaders: [],
			}
		},
		methods: {
			//往年调剂情况
			getAdjustYearInfoData() {
				uni.showLoading({
					mask: true
				});
				getAdjustYearInfo({
					schoolCode: this.schoolCode,
					collegeCode: this.collegeCode,
					majorCode: this.majorCode
				}).then(res => {
					if (res.code == 100000) {
						this.retestHeaders = [{
							label: '年份',
							key: 'Type',
						}]
						this.receiveHeaders = [{
							label: '年份',
							key: 'Type',
						}]
						let data = res.data[0].accept;
						let list = [{
							Type: '是否接收调剂',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '接收调剂人数',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '接收同校调剂人数',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '调剂录取最低分',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '调剂录取平均分',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '调剂录取最高分',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}]
						let num = "";
						for (let b1 in data.acceptNumbers) {
							if (b1 == 1) {
								num = "ASecondYear"
								this.receiveHeaders.push({
									label: data.acceptNumbers[b1].year,
									key: 'ASecondYear',
								})
							} else if (b1 == 2) {
								num = "AThirdYear"
								this.receiveHeaders.push({
									label: data.acceptNumbers[b1].year,
									key: 'AThirdYear',
								})
							} else if (b1 == 3) {
								num = "FourthYear"
								this.receiveHeaders.push({
									label: data.acceptNumbers[b1].year,
									key: 'FourthYear',
								})
							} else {
								num = "AFirstYear";
								this.receiveHeaders.push({
									label: data.acceptNumbers[b1].year,
									key: 'AFirstYear',
								})
							}
							list[0][num] = data.isAccepts.length ? (data.isAccepts[b1].body ? '是' : '否') : '否';
							list[1][num] = data.acceptNumbers.length ? data.acceptNumbers[b1].body : 0;
							list[2][num] = data.acceptSameSchoolNumbers.length ? data.acceptSameSchoolNumbers[b1].body : 0;
							list[3][num] = data.minNumbers.length ? data.minNumbers[b1].body : 0;
							list[4][num] = data.avgNumbers.length ? data.avgNumbers[b1].body : 0;
							list[5][num] = data.maxNumbers.length ? data.maxNumbers[b1].body : 0;
						}
						this.receiveTableData = list;
						let retest = res.data[0].retest;
						let retestList = [{
							Type: '总分',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '英语',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '政治',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '专一',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}, {
							Type: '专二',
							AFirstYear: 0,
							ASecondYear: 0,
							AThirdYear: 0,
							FourthYear: 0
						}]

						let retestNum = "";
						for (let b1 in retest.avgNumbers) {
							if (b1 == 1) {
								retestNum = "ASecondYear"
								this.retestHeaders.push({
									label: retest.avgNumbers[b1].year,
									key: 'ASecondYear',
								})
							} else if (b1 == 2) {
								retestNum = "AThirdYear"
								this.retestHeaders.push({
									label: retest.avgNumbers[b1].year,
									key: 'AThirdYear',
								})
							} else if (b1 == 3) {
								retestNum = "FourthYear"
								this.retestHeaders.push({
									label: retest.avgNumbers[b1].year,
									key: 'FourthYear',
								})
							} else {
								retestNum = "AFirstYear";
								this.retestHeaders.push({
									label: retest.avgNumbers[b1].year,
									key: 'AFirstYear',
								})
							}
							retestList[0][retestNum] = retest.scores.length ? retest.scores[b1].body : 0;
							retestList[1][retestNum] = retest.englishScores.length ? retest.englishScores[b1].body : 0;
							retestList[2][retestNum] = retest.politicsScores.length ? retest.politicsScores[b1].body : 0;
							retestList[3][retestNum] = retest.major1Scores.length ? retest.major1Scores[b1].body : 0;
							retestList[4][retestNum] = retest.major2Scores.length ? retest.major2Scores[b1].body : 0;
						}
						this.fractionTableData = retestList;
					}
				}).finally(() => {
					uni.hideLoading();
				})
			},
		}
	}
</script>

<style>
</style>